//
//  LOLSettingCell.m
//  LOL_Little_Box
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "LOLSettingCell.h"
#import "LOLLabel.h"
#import "LOLImageView.h"
#import "LWSCoculateSize.h"

@interface LOLSettingCell ()

@property (nonatomic , retain)LOLLabel *labelTitle;
@property (nonatomic , retain)LOLLabel *labelDetial;
@property (nonatomic , retain)UIImageView *showImages;

@end

@implementation LOLSettingCell

- (void)setContains:(NSDictionary *)contains{
    _contains = contains;
    NSString *key = [[_contains allKeys] firstObject];
    self.labelTitle.text = key;
    self.labelDetial.text = [_contains valueForKey:key];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.labelTitle = [[LOLLabel alloc]initWithFrame:CGRectZero];
        self.labelDetial = [[LOLLabel alloc]initWithFrame:CGRectZero];
        
        self.labelTitle.font = [UIFont systemFontOfSize:15.0];
        self.labelDetial.font = [UIFont systemFontOfSize:13.0];
        
        self.labelDetial.textColor = [UIColor darkGrayColor];
        
        [self.contentView addSubview:self.labelDetial];
        [self.contentView addSubview:self.labelTitle];
        self.showImages = [[LOLImageView alloc]initWithFrame:CGRectZero];
        self.showImages.image = [UIImage imageNamed:@"battle_data_img_arrow@2x"];
        [self.contentView addSubview:self.showImages];
    }
    return  self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat width = [LWSCoculateSize getCurrentLabelWidthByLabelText:self.labelTitle.text Font:self.labelTitle.font LabelHeight:20];
    CGRect frame = CGRectMake(20, 10, width, 20);
    self.labelTitle.frame = frame;
    CGPoint center = self.labelTitle.center;
    center.y = self.contentView.center.y;
    self.labelTitle.center = center;
    
    frame.size.width = [LWSCoculateSize getCurrentLabelWidthByLabelText:self.labelDetial.text Font:self.labelDetial.font LabelHeight:20];
    frame.origin.x = self.contentView.frame.size.width - frame.size.width - 30;
    self.labelDetial.frame = frame;
    center = self.labelDetial.center;
    center.y = self.contentView.center.y;
    self.labelDetial.center = center;
    
    frame.origin.x += frame.size.width + 10;
    frame.size = self.showImages.image.size;
    self.showImages.frame = frame;
    center = self.showImages.center;
    center.y = self.contentView.center.y;
    self.showImages.center = center;

}

@end
